import request from '@/utils/request'

export const getAllCouse = () => {
  return request({
    url: '/admin/courses',
    method: 'GET'
  })
}

export const addCourse = (course) => {
  return request({
    url: '/admin/course',
    method: 'POST',
    data: {
      id: course.id,
      name: course.name,
      credit: course.credit,
      teacherId: course.teacherId,
      classTime: course.classTime,
      type: course.type
    }
  })
}

export const getCourseListByTeacherId = (teacherId) => {
  return request({
    url: '/teacher/course',
    method: 'GET',
    params: {
      teacherId: teacherId
    }
  })
}

export const getRecordByStudentId = (studentId) => {
  return request({
    url: '/student/record',
    method: 'GET',
    params: {
      id: studentId
    }
  })
}

export const selectCourse = (studentId, courseId) => {
  return request({
    url: '/student/record',
    method: 'POST',
    params: {
      studentId: studentId,
      courseId: courseId
    }
  })
}

export const courseDetail = (courseId) => {
  return request({
    url: '/teacher/course/detail',
    method: 'GET',
    params: {
      courseId: courseId
    }
  })
}

export const getAllRecords = () => {
  return request({
    url: '/admin/record',
    method: 'GET'
  })
}
